test(git): add tests for get_filenames_in_commit with git_reference#1890
test(git): add tests for get_filenames_in_commit with git_reference#1890HankyStyle wants to merge 2 commits intocommitizen-tools:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1890 +/- ##
=======================================
Coverage 97.99% 97.99%
=======================================
Files 60 60
Lines 2689 2689
=======================================
Hits 2635 2635
Misses 54 54 ☔ View full report in Codecov by Sentry. |
tests/test_git.py
Outdated
| util.create_file_and_commit("feat: add new feature", filename=filename) | ||
|
|
||
| filenames = git.get_filenames_in_commit() | ||
| assert filename in filenames |
There was a problem hiding this comment.
should it be
| assert filename in filenames | |
| assert [filename] == filenames |
instead?
There was a problem hiding this comment.
+1
and probably add another commit with more files to validate the behavior that the function only resolves filenames from the last commit
There was a problem hiding this comment.
@Lee-W @bearomorphism
Thanks for the suggestion! Updated.
- Add a prior commit to verify only the last commit's files are returned - Use strict equality assertion instead of in
| @pytest.mark.usefixtures("tmp_commitizen_project") | ||
| def test_get_filenames_in_commit(util: UtilFixture): | ||
| """Test get_filenames_in_commit returns filenames from the last commit.""" | ||
| util.create_file_and_commit("feat: old feature", filename="old_file.txt") |
There was a problem hiding this comment.
Added a prior commit in here so we can validate that the function only returns files from the last commit.
HankyStyle
left a comment
There was a problem hiding this comment.
Add a comment to the code change.
Description
Add missing test coverage for the
get_filenames_in_commitfunction.This PR adds:
test_get_filenames_in_commit: happy path test withoutgit_reference, verifying correct filenames are returned from the last committest_get_filenames_in_commit_with_git_reference: happy path test with a specific commit SHA asgit_reference, verifying only files from that specific commit are returnedCloses #1860
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.6 + Antigravity
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
Running
uv run pytest tests/test_git.py -k "get_filenames_in_commit"should pass all 3 tests:test_get_filenames_in_commit— returns correct filename from the last committest_get_filenames_in_commit_with_git_reference— returns only files from the specified commit SHA, not from other commitstest_get_filenames_in_commit_error— raisesGitCommandErrorwhen git command fails (existing test, unchanged)Steps to Test This Pull Request
Additional Context
Related issue: #1860